package com.example.reflection.config;

import com.example.reflection.service.UserService;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class InterfaceInvocationHandler implements InvocationHandler {
    private final UserService userService;

    public InterfaceInvocationHandler(UserService userService) {
        this.userService = userService;
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("---------before-------");
        Object invoke = method.invoke(userService, args);
        System.out.println("---------after-------");

        return invoke;
    }
}
